import numpy as np
import pandas as pd
import seaborn as sns
sns.set(style="whitegrid")
import matplotlib.pyplot as plt
from collections import Counter
%matplotlib inline
import warnings
warnings.filterwarnings('ignore')
fifa=pd.read_csv(r'E:\DS Course\2. July\28th\Seaborn\FIFA.csv')
fifa
| Unnamed: 0 | ID | Name | Age | Photo | Nationality | Flag | Overall | Potential | Club | ... | Composure | Marking | StandingTackle | SlidingTackle | GKDiving | GKHandling | GKKicking | GKPositioning | GKReflexes | Release Clause | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 158023 | L. Messi | 31 | https://cdn.sofifa.org/players/4/19/158023.png | Argentina | https://cdn.sofifa.org/flags/52.png | 94 | 94 | FC Barcelona | ... | 96.0 | 33.0 | 28.0 | 26.0 | 6.0 | 11.0 | 15.0 | 14.0 | 8.0 | €226.5M |
| 1 | 1 | 20801 | Cristiano Ronaldo | 33 | https://cdn.sofifa.org/players/4/19/20801.png | Portugal | https://cdn.sofifa.org/flags/38.png | 94 | 94 | Juventus | ... | 95.0 | 28.0 | 31.0 | 23.0 | 7.0 | 11.0 | 15.0 | 14.0 | 11.0 | €127.1M |
| 2 | 2 | 190871 | Neymar Jr | 26 | https://cdn.sofifa.org/players/4/19/190871.png | Brazil | https://cdn.sofifa.org/flags/54.png | 92 | 93 | Paris Saint-Germain | ... | 94.0 | 27.0 | 24.0 | 33.0 | 9.0 | 9.0 | 15.0 | 15.0 | 11.0 | €228.1M |
| 3 | 3 | 193080 | De Gea | 27 | https://cdn.sofifa.org/players/4/19/193080.png | Spain | https://cdn.sofifa.org/flags/45.png | 91 | 93 | Manchester United | ... | 68.0 | 15.0 | 21.0 | 13.0 | 90.0 | 85.0 | 87.0 | 88.0 | 94.0 | €138.6M |
| 4 | 4 | 192985 | K. De Bruyne | 27 | https://cdn.sofifa.org/players/4/19/192985.png | Belgium | https://cdn.sofifa.org/flags/7.png | 91 | 92 | Manchester City | ... | 88.0 | 68.0 | 58.0 | 51.0 | 15.0 | 13.0 | 5.0 | 10.0 | 13.0 | €196.4M |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 18202 | 18202 | 238813 | J. Lundstram | 19 | https://cdn.sofifa.org/players/4/19/238813.png | England | https://cdn.sofifa.org/flags/14.png | 47 | 65 | Crewe Alexandra | ... | 45.0 | 40.0 | 48.0 | 47.0 | 10.0 | 13.0 | 7.0 | 8.0 | 9.0 | €143K |
| 18203 | 18203 | 243165 | N. Christoffersson | 19 | https://cdn.sofifa.org/players/4/19/243165.png | Sweden | https://cdn.sofifa.org/flags/46.png | 47 | 63 | Trelleborgs FF | ... | 42.0 | 22.0 | 15.0 | 19.0 | 10.0 | 9.0 | 9.0 | 5.0 | 12.0 | €113K |
| 18204 | 18204 | 241638 | B. Worman | 16 | https://cdn.sofifa.org/players/4/19/241638.png | England | https://cdn.sofifa.org/flags/14.png | 47 | 67 | Cambridge United | ... | 41.0 | 32.0 | 13.0 | 11.0 | 6.0 | 5.0 | 10.0 | 6.0 | 13.0 | €165K |
| 18205 | 18205 | 246268 | D. Walker-Rice | 17 | https://cdn.sofifa.org/players/4/19/246268.png | England | https://cdn.sofifa.org/flags/14.png | 47 | 66 | Tranmere Rovers | ... | 46.0 | 20.0 | 25.0 | 27.0 | 14.0 | 6.0 | 14.0 | 8.0 | 9.0 | €143K |
| 18206 | 18206 | 246269 | G. Nugent | 16 | https://cdn.sofifa.org/players/4/19/246269.png | England | https://cdn.sofifa.org/flags/14.png | 46 | 66 | Tranmere Rovers | ... | 43.0 | 40.0 | 43.0 | 50.0 | 10.0 | 15.0 | 9.0 | 12.0 | 9.0 | €165K |
18207 rows × 89 columns
fifa.head()
| Unnamed: 0 | ID | Name | Age | Photo | Nationality | Flag | Overall | Potential | Club | ... | Composure | Marking | StandingTackle | SlidingTackle | GKDiving | GKHandling | GKKicking | GKPositioning | GKReflexes | Release Clause | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 158023 | L. Messi | 31 | https://cdn.sofifa.org/players/4/19/158023.png | Argentina | https://cdn.sofifa.org/flags/52.png | 94 | 94 | FC Barcelona | ... | 96.0 | 33.0 | 28.0 | 26.0 | 6.0 | 11.0 | 15.0 | 14.0 | 8.0 | €226.5M |
| 1 | 1 | 20801 | Cristiano Ronaldo | 33 | https://cdn.sofifa.org/players/4/19/20801.png | Portugal | https://cdn.sofifa.org/flags/38.png | 94 | 94 | Juventus | ... | 95.0 | 28.0 | 31.0 | 23.0 | 7.0 | 11.0 | 15.0 | 14.0 | 11.0 | €127.1M |
| 2 | 2 | 190871 | Neymar Jr | 26 | https://cdn.sofifa.org/players/4/19/190871.png | Brazil | https://cdn.sofifa.org/flags/54.png | 92 | 93 | Paris Saint-Germain | ... | 94.0 | 27.0 | 24.0 | 33.0 | 9.0 | 9.0 | 15.0 | 15.0 | 11.0 | €228.1M |
| 3 | 3 | 193080 | De Gea | 27 | https://cdn.sofifa.org/players/4/19/193080.png | Spain | https://cdn.sofifa.org/flags/45.png | 91 | 93 | Manchester United | ... | 68.0 | 15.0 | 21.0 | 13.0 | 90.0 | 85.0 | 87.0 | 88.0 | 94.0 | €138.6M |
| 4 | 4 | 192985 | K. De Bruyne | 27 | https://cdn.sofifa.org/players/4/19/192985.png | Belgium | https://cdn.sofifa.org/flags/7.png | 91 | 92 | Manchester City | ... | 88.0 | 68.0 | 58.0 | 51.0 | 15.0 | 13.0 | 5.0 | 10.0 | 13.0 | €196.4M |
5 rows × 89 columns
fifa.tail()
| Unnamed: 0 | ID | Name | Age | Photo | Nationality | Flag | Overall | Potential | Club | ... | Composure | Marking | StandingTackle | SlidingTackle | GKDiving | GKHandling | GKKicking | GKPositioning | GKReflexes | Release Clause | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 18202 | 18202 | 238813 | J. Lundstram | 19 | https://cdn.sofifa.org/players/4/19/238813.png | England | https://cdn.sofifa.org/flags/14.png | 47 | 65 | Crewe Alexandra | ... | 45.0 | 40.0 | 48.0 | 47.0 | 10.0 | 13.0 | 7.0 | 8.0 | 9.0 | €143K |
| 18203 | 18203 | 243165 | N. Christoffersson | 19 | https://cdn.sofifa.org/players/4/19/243165.png | Sweden | https://cdn.sofifa.org/flags/46.png | 47 | 63 | Trelleborgs FF | ... | 42.0 | 22.0 | 15.0 | 19.0 | 10.0 | 9.0 | 9.0 | 5.0 | 12.0 | €113K |
| 18204 | 18204 | 241638 | B. Worman | 16 | https://cdn.sofifa.org/players/4/19/241638.png | England | https://cdn.sofifa.org/flags/14.png | 47 | 67 | Cambridge United | ... | 41.0 | 32.0 | 13.0 | 11.0 | 6.0 | 5.0 | 10.0 | 6.0 | 13.0 | €165K |
| 18205 | 18205 | 246268 | D. Walker-Rice | 17 | https://cdn.sofifa.org/players/4/19/246268.png | England | https://cdn.sofifa.org/flags/14.png | 47 | 66 | Tranmere Rovers | ... | 46.0 | 20.0 | 25.0 | 27.0 | 14.0 | 6.0 | 14.0 | 8.0 | 9.0 | €143K |
| 18206 | 18206 | 246269 | G. Nugent | 16 | https://cdn.sofifa.org/players/4/19/246269.png | England | https://cdn.sofifa.org/flags/14.png | 46 | 66 | Tranmere Rovers | ... | 43.0 | 40.0 | 43.0 | 50.0 | 10.0 | 15.0 | 9.0 | 12.0 | 9.0 | €165K |
5 rows × 89 columns
fifa.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 18207 entries, 0 to 18206 Data columns (total 89 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Unnamed: 0 18207 non-null int64 1 ID 18207 non-null int64 2 Name 18207 non-null object 3 Age 18207 non-null int64 4 Photo 18207 non-null object 5 Nationality 18207 non-null object 6 Flag 18207 non-null object 7 Overall 18207 non-null int64 8 Potential 18207 non-null int64 9 Club 17966 non-null object 10 Club Logo 18207 non-null object 11 Value 18207 non-null object 12 Wage 18207 non-null object 13 Special 18207 non-null int64 14 Preferred Foot 18159 non-null object 15 International Reputation 18159 non-null float64 16 Weak Foot 18159 non-null float64 17 Skill Moves 18159 non-null float64 18 Work Rate 18159 non-null object 19 Body Type 18159 non-null object 20 Real Face 18159 non-null object 21 Position 18147 non-null object 22 Jersey Number 18147 non-null float64 23 Joined 16654 non-null object 24 Loaned From 1264 non-null object 25 Contract Valid Until 17918 non-null object 26 Height 18159 non-null object 27 Weight 18159 non-null object 28 LS 16122 non-null object 29 ST 16122 non-null object 30 RS 16122 non-null object 31 LW 16122 non-null object 32 LF 16122 non-null object 33 CF 16122 non-null object 34 RF 16122 non-null object 35 RW 16122 non-null object 36 LAM 16122 non-null object 37 CAM 16122 non-null object 38 RAM 16122 non-null object 39 LM 16122 non-null object 40 LCM 16122 non-null object 41 CM 16122 non-null object 42 RCM 16122 non-null object 43 RM 16122 non-null object 44 LWB 16122 non-null object 45 LDM 16122 non-null object 46 CDM 16122 non-null object 47 RDM 16122 non-null object 48 RWB 16122 non-null object 49 LB 16122 non-null object 50 LCB 16122 non-null object 51 CB 16122 non-null object 52 RCB 16122 non-null object 53 RB 16122 non-null object 54 Crossing 18159 non-null float64 55 Finishing 18159 non-null float64 56 HeadingAccuracy 18159 non-null float64 57 ShortPassing 18159 non-null float64 58 Volleys 18159 non-null float64 59 Dribbling 18159 non-null float64 60 Curve 18159 non-null float64 61 FKAccuracy 18159 non-null float64 62 LongPassing 18159 non-null float64 63 BallControl 18159 non-null float64 64 Acceleration 18159 non-null float64 65 SprintSpeed 18159 non-null float64 66 Agility 18159 non-null float64 67 Reactions 18159 non-null float64 68 Balance 18159 non-null float64 69 ShotPower 18159 non-null float64 70 Jumping 18159 non-null float64 71 Stamina 18159 non-null float64 72 Strength 18159 non-null float64 73 LongShots 18159 non-null float64 74 Aggression 18159 non-null float64 75 Interceptions 18159 non-null float64 76 Positioning 18159 non-null float64 77 Vision 18159 non-null float64 78 Penalties 18159 non-null float64 79 Composure 18159 non-null float64 80 Marking 18159 non-null float64 81 StandingTackle 18159 non-null float64 82 SlidingTackle 18159 non-null float64 83 GKDiving 18159 non-null float64 84 GKHandling 18159 non-null float64 85 GKKicking 18159 non-null float64 86 GKPositioning 18159 non-null float64 87 GKReflexes 18159 non-null float64 88 Release Clause 16643 non-null object dtypes: float64(38), int64(6), object(45) memory usage: 12.4+ MB
fifa['Body Type'].value_counts()
Normal 10595 Lean 6417 Stocky 1140 Messi 1 C. Ronaldo 1 Neymar 1 Courtois 1 PLAYER_BODY_TYPE_25 1 Shaqiri 1 Akinfenwa 1 Name: Body Type, dtype: int64
Visualize distribution of Age variable with Seaborn distplot() function
Seaborn distplot() function flexibly plots a univariate distribution of observations.
This function combines the matplotlib hist function (with automatic calculation of a good default bin size) with the seaborn kdeplot() and rugplot() functions.
So, let's visualize the distribution of Age variable with Seaborn distplot() function.
f,ax=plt.subplots(figsize=(8,6))
x=fifa['Age']
ax=sns.distplot(x,bins=10)
plt.show()
the Age variable is slightly positively skewed.
We can use Pandas series object to get an informative axis label as follows-
f,ax=plt.subplots(figsize=(8,6))
x=fifa['Age']
x=pd.Series(x,name="Age variable")
ax=sns.distplot(x,bins=10)
plt.show()
f,ax=plt.subplots(figsize=(8,6))
x=fifa['Age']
ax=sns.distplot(x,bins=10,vertical=True)
plt.show()
f,ax=plt.subplots(figsize=(8,6))
x=fifa['Age']
x=pd.Series(x,name="Age variable")
ax=sns.kdeplot(x)
plt.show()
f,ax=plt.subplots(figsize=(8,6))
x=fifa['Age']
x=pd.Series(x,name="Age Variable")
ax=sns.kdeplot(x,shade=True,color='r')
plt.show()
f,ax=plt.subplots(figsize=(8,6))
x=fifa['Age']
ax=sns.distplot(x,kde=False,rug=True,bins=10)
plt.show()
f,ax=plt.subplots(figsize=(8,6))
x=fifa['Age']
ax=sns.distplot(x,hist=False,rug=True,bins=10)
plt.show()
fifa['Preferred Foot'].nunique()
2
fifa['Preferred Foot'].unique()
array(['Left', 'Right', nan], dtype=object)
fifa['Preferred Foot'].value_counts()
Right 13948 Left 4211 Name: Preferred Foot, dtype: int64
f,ax=plt.subplots(figsize=(8,6))
sns.countplot(x="Preferred Foot",data=fifa,color='g')
plt.show()
f,ax=plt.subplots(figsize=(8,6))
sns.countplot(x="Preferred Foot",hue="Real Face",data=fifa)
plt.show()
g=sns.catplot(x="Preferred Foot",kind="count",palette="ch:.25",data=fifa)
fifa['International Reputation'].nunique()
5
fifa['International Reputation'].unique()
array([ 5., 4., 3., 2., 1., nan])
fifa['International Reputation'].value_counts()
1.0 16532 2.0 1261 3.0 309 4.0 51 5.0 6 Name: International Reputation, dtype: int64
f,ax=plt.subplots(figsize=(8,6))
sns.stripplot(x="International Reputation",y="Potential",data=fifa)
plt.show()
We can add jitter to bring out the distribution of values as follows
f,ax=plt.subplots(figsize=(8,6))
sns.stripplot(x="International Reputation",y="Potential",data=fifa,jitter=0.01)
plt.show()
f,ax=plt.subplots(figsize=(8,6))
sns.stripplot(x="International Reputation",y="Potential",hue="Preferred Foot",data=fifa,jitter=0.2,palette="Set2",dodge=True)
plt.show()
f,ax=plt.subplots(figsize=(8,6))
sns.stripplot(x="International Reputation",y="Potential",hue="Preferred Foot",data=fifa,palette="Set2",size=20,marker="D",edgecolor="gray",alpha=.25)
plt.show()
f,ax=plt.subplots(figsize=(8,6))
sns.boxplot(y=fifa["Potential"])
plt.show()
f,ax=plt.subplots(figsize=(8,6))
sns.boxplot(x="International Reputation",y="Potential",data=fifa)
plt.show()
plt.subplots(figsize=(8,6))
sns.boxplot(x="International Reputation",y="Potential",hue="Preferred Foot",data=fifa,palette="Set3")
plt.show()
f,ax=plt.subplots(figsize=(8,6))
sns.violinplot(x=fifa["Potential"])
plt.show()
We can draw the vertical violinplot grouped by the categorical variable International Reputation as follows
f,ax=plt.subplots(figsize=(8,6))
sns.violinplot(x="International Reputation",y="Potential",data=fifa)
plt.show()
f,ax=plt.subplots(figsize=(8,6))
sns.violinplot(x="International Reputation",y="Potential",hue="Preferred Foot",data=fifa,palette="muted")
plt.show()
We can draw split violins to compare the across the hue variable as follows
f,ax=plt.subplots(figsize=(8,6))
sns.violinplot(x="International Reputation",y="Potential",hue="Preferred Foot",data=fifa,palette="muted",split=True)
plt.show()
f,ax=plt.subplots(figsize=(8,6)) sns.pointplot(x="International Reputation",y="Potential",data=fifa) plt.show()
f,ax=plt.subplots(figsize=(8,6))
sns.pointplot(x="International Reputation",y="Potential",hue="Preferred Foot",data=fifa)
plt.show()
We can separate the points for different hue levels along the categorical axis as follows
f,ax=plt.subplots(figsize=(8,6))
sns.pointplot(x="International Reputation",y="Potential",hue="Preferred Foot",data=fifa,dodge=True)
plt.show()
We can use a different marker and line style for the hue levels as follows
f,ax=plt.subplots(figsize=(8,6))
sns.pointplot(x="International Reputation",y="Potential",hue="Preferred Foot",data=fifa,markers=["o","x"],linestyles=["-","--"])
plt.show()
f,ax=plt.subplots(figsize=(8,6))
sns.barplot(x="International Reputation",y="Potential",data=fifa)
plt.show()
f,ax=plt.subplots(figsize=(8,6))
sns.barplot(x="International Reputation",y="Potential",hue="Preferred Foot",data=fifa)
plt.show()
We can use median as the estimate of central tendency as follows
from numpy import median
f,ax=plt.subplots(figsize=(8,6))
sns.barplot(x="International Reputation",y="Potential",data=fifa,estimator=median)
plt.show()
We can show the standard error of the mean with the error bars as follows
f,ax=plt.subplots(figsize=(8,6))
sns.barplot(x="International Reputation",y="Potential",data=fifa,ci=68)
plt.show()
We can show standard deviation of observations instead of a confidence interval as follows
f,ax=plt.subplots(figsize=(8,6))
sns.barplot(x="International Reputation",y="Potential",data=fifa,ci="sd")
plt.show()
We can add “caps” to the error bars as follows
f,ax=plt.subplots(figsize=(8,6))
sns.barplot(x="International Reputation",y="Potential",data=fifa,capsize=0.3)
plt.show()
Seaborn relplot() function helps us to draw figure-level interface for drawing relational plots onto a FacetGrid.
This function provides access to several different axes-level functions that show the relationship between two variables with semantic mappings of subsets.
The kind parameter selects the underlying axes-level function to use-
scatterplot() (with kind="scatter"; the default)
lineplot() (with kind="line")
We can plot a scatterplot with variables Heigh and Weight with Seaborn relplot() function as follows
g=sns.relplot(x="Overall",y="Potential",data=fifa)
Seaborn scatterplot() function
This function draws a scatter plot with possibility of several semantic groups.
The relationship between x and y can be shown for different subsets of the data using the hue, size and style parameters.
These parameters control what visual semantics are used to identify the different subsets.
f,ax=plt.subplots(figsize=(8,6))
sns.scatterplot(x="Height",y="Weight",data=fifa)
plt.show()
Seaborn lineplot() function
THis function draws a line plot with possibility of several semantic groupings.
The relationship between x and y can be shown for different subsets of the data using the hue, size and style parameters.
These parameters control what visual semantics are used to identify the different subsets.
f,ax=plt.subplots(figsize=(8,6))
ax=sns.lineplot(x="Stamina",y="Strength",data=fifa)
plt.show()
Seaborn regplot() function
This function plots data and a linear regression model fit. We can plot a linear regression model between Overall and Potential variable with regplot() function as follows-
f,ax=plt.subplots(figsize=(8,6))
ax=sns.regplot(x="Overall",y="Potential",data=fifa)
plt.show()
f,ax=plt.subplots(figsize=(8,6))
ax=sns.regplot(x="Overall",y="Potential",data=fifa,color="g",marker="*")
plt.show()
f,ax=plt.subplots(figsize=(8,6))
ax=sns.regplot(x="International Reputation",y="Potential",data=fifa)
plt.show()
g=sns.lmplot(x="Overall",y="Potential",data=fifa)
g=sns.lmplot(x="Overall",y="Potential",hue="Preferred Foot",data=fifa)
g=sns.lmplot(x="Overall",y="Potential",hue="Preferred Foot",data=fifa,palette="Set1")
g=sns.lmplot(x="Overall",y="Potential",col="Preferred Foot",data=fifa)
The FacetGrid class is useful when you want to visualize the distribution of a variable or the relationship between multiple variables separately within subsets of your dataset.
A FacetGrid can be drawn with up to three dimensions - row, col and hue. The first two have obvious correspondence with the resulting array of axes - the hue variable is a third dimension along a depth axis, where different levels are plotted with different colors.
The class is used by initializing a FacetGrid object with a dataframe and the names of the variables that will form the row, column or hue dimensions of the grid.
These variables should be categorical or discrete, and then the data at each level of the variable will be used for a facet along that axis.
g=sns.FacetGrid(fifa,col="Preferred Foot")
g = sns.FacetGrid(fifa, col="Preferred Foot")
g = g.map(plt.hist, "Potential")
g=sns.FacetGrid(fifa,col="Preferred Foot")
g=g.map(plt.hist,"Potential",bins=10,color="r")
g=sns.FacetGrid(fifa,col="Preferred Foot")
g=(g.map(plt.scatter,"Height","Weight",edgecolor="w").add_legend())
The size of the figure is set by providing the height of each facet, along with the aspect ratio
g=sns.FacetGrid(fifa,col="Preferred Foot",height=5,aspect=1)
g=g.map(plt.hist,"Potential")
This function plots subplot grid for plotting pairwise relationships in a dataset.
This class maps each variable in a dataset onto a column and row in a grid of multiple axes.
Different axes-level plotting functions can be used to draw bivariate plots in the upper and lower triangles, and the the marginal distribution of each variable can be shown on the diagonal.
It can also represent an additional level of conditionalization with the hue parameter, which plots different subets of data in different colors.
This uses color to resolve elements on a third dimension, but only draws subsets on top of each other and will not tailor the hue parameter for the specific visualization the way that axes-level functions that accept hue will.
fifa_new=fifa[['Age','Potential','Strength','Stamina','Preferred Foot']]
g=sns.PairGrid(fifa_new)
g=g.map(plt.scatter)
g=sns.PairGrid(fifa_new)
g=g.map_diag(plt.hist)
g=g.map_offdiag(plt.scatter)
g=sns.PairGrid(fifa_new,hue="Preferred Foot")
g=g.map_diag(plt.hist)
g=g.map_offdiag(plt.scatter)
g=g.add_legend()
g=sns.PairGrid(fifa_new,hue="Preferred Foot")
g=g.map_diag(plt.hist,histtype="step",linewidth=3)
g=g.map_offdiag(plt.scatter)
g=g.add_legend()
g=sns.PairGrid(fifa_new,vars=['Age','Stamina'])
g=g.map(plt.scatter)
g=sns.JointGrid(x="Overall",y="Potential",data=fifa)
g=g.plot(sns.regplot,sns.distplot)
import matplotlib.pyplot as plt
g=sns.JointGrid(x="Overall",y="Potential",data=fifa)
g=g.plot_joint(plt.scatter,color=".5",edgecolor="white")
g=g.plot_marginals(sns.distplot,kde=False,color=".5")
g=sns.JointGrid(x="Overall",y="Potential",data=fifa,space=0)
g=g.plot_joint(sns.kdeplot,cmap="Blues_d")
g=g.plot_marginals(sns.kdeplot,shade=True)
g=sns.JointGrid(x="Overall",y="Potential",data=fifa,height=5,ratio=2)
g=g.plot_joint(sns.kdeplot,cmap="Reds_d")
g=g.plot_marginals(sns.kdeplot,color="r",shade=True)
f,ax=plt.subplots(figsize=(8,6))
ax=sns.regplot(x="Overall",y="Potential",data=fifa)
sns.lmplot(x="Overall",y="Potential",col="Preferred Foot",data=fifa,col_wrap=2,height=5,aspect=1)
plt.show()
There are five preset seaborn themes: darkgrid, whitegrid, dark, white and ticks.
They are each suited to different applications and personal preferences.
The default theme is darkgrid.
The grid helps the plot serve as a lookup table for quantitative information, and the white-on grey helps to keep the grid from competing with lines that represent data.
The whitegrid theme is similar, but it is better suited to plots with heavy data elements:
def sinplot(flip=1):
x = np.linspace(0, 14, 100)
for i in range(1, 7):
plt.plot(x, np.sin(x + i * .5) * (7 - i) * flip)
sinplot()
sns.set()
sinplot()
sns.set_style("whitegrid")
sinplot()
sns.set_style("dark")
sinplot()
sns.set_style("white")
sinplot()
sns.set_style("ticks")
sinplot()